package initialize

import (
	"log"
	"sync/atomic"
	"ug-uploads/config"
	"ug-uploads/db"
	"ug-uploads/logx"
)

type Stats struct {
	AdvertiserCount int64
	JumpCount       int64
	Success         int64
}

var StatsInfo Stats

func Init() {
	err := logx.Init()
	if err != nil {
		log.Fatal("日志系统初始化失败", err)
	}
	err = config.Init()
	if err != nil {
		log.Fatal("配置系统初始化失败", err)
	}
	err = db.Init()
	if err != nil {
		log.Fatal("数据库系统初始化失败", err)
	}
}

func ResetCounter() {
	// StatsInfo.AdvertiserCount = 0
	// StatsInfo.JumpCount = 0
	// StatsInfo.Success = 0
	atomic.StoreInt64(&StatsInfo.AdvertiserCount, 0)
	atomic.StoreInt64(&StatsInfo.JumpCount, 0)
	atomic.StoreInt64(&StatsInfo.Success, 0)
}
